/**
 * 
 */
package de.preamp.clients.java.playlist.ui;

import java.awt.Color;
import java.awt.Component;

import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;

import de.preamp.clients.java.data.Track;
import de.preamp.clients.java.playlist.Playlist;

/**
 * @author stonedsquirrel
 */
public class PlaylistCellRenderer extends JLabel implements ListCellRenderer
{
    /**
     * generated UID.
     */
    private static final long serialVersionUID = -1151643716304798402L;

    @Override
    public final Component getListCellRendererComponent(final JList list,
	    final Object value, final int index, final boolean isSelected,
	    final boolean cellHasFocus)
    {
	JLabel component = new JLabel();

	if (value instanceof Playlist)
	{
	    component = new JLabel(((Playlist) value).getName());
	    if (isSelected)
	    {
		component.setForeground(Color.BLUE);
	    }
	    else
	    {
		component.setForeground(Color.BLACK);
	    }
	}
	else if (value instanceof Track)
	{
	    component = new JLabel();
	}

	return component;
    }

}
